using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

using Utility = PHSRAG.Utility;

namespace PHSRAG.Insight21
{
    /// <summary>
    /// Summary description for CommonLookup
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    public class CommonLookup : System.Web.Services.WebService
    {

        [WebMethod]
        public string[] GetPIs(string prefixText, int count, string contextKey)
        {
            ArrayList returnList = new ArrayList();
            DataTable table = new DataTable();
            Utility.DataAccess.LoadDataTable(table, Utility.DataAccess.ConnectionString, "GetPIList",
                Utility.DataAccess.BuildSqlParameterArray("@domainUserID", SqlDbType.Int, Int32.Parse(contextKey),
                "@piName", SqlDbType.VarChar, prefixText));

            foreach (DataRow row in table.Rows)
            {
                returnList.Add(row[1].ToString());
            }

            return (string[])returnList.ToArray(typeof(System.String));
        }

    }

}